<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\Filters;

class PowerLog extends Model
{
    use Filters;
    
    protected $table = 'power_log';

    protected static function add_log($user_id,$type,$power,$status,$comment="")
    {
        PowerLog::insert([
            'user_id' =>$user_id,
            'type' =>$type,
            'power' =>$power,
            'status' =>$status,
            'comment' =>$comment,
            'created_at' =>date('Y-m-d H:i:s'),
            'updated_at' =>date('Y-m-d H:i:s'),
        ]);
    }


    public function powertype()
    {
        return $this->belongsTo(PowerType::class,'type','id');
    }

    public function user()
    {
        return $this->belongsTo(user::class);
    }
}
